<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>好文推荐</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" type="text/css" href="../../css/mui.min.css" />
		<style>
			*{
				padding: 0px;
				border: 0px;
				margin: 0px;
				font-family: "黑体";
			}
			#dv-serach{
				position: fixed;
				width: 100%;
				height: 50px;
				top: 10px;
				background-color: #fafafa;
			}
		</style>
	</head>
	<body style="background-color: white;">
		<div class="mui-content">
			<div id="dv-serach" style="">
				<input type="search" placeholder="Search" style="height: 40px; background-color: white; font-size: 17px;"/>
			</div>
			
			<div id="rfc-goodTxtLst" class="mui-scroll-wrapper" style="height: 92%; top: 70px; background-color: white;">
				<div class="mui-scroll">
					<div id="ul-goodTxtLst">

					</div>
				</div>
			</div>
		</div>
	</body>
	<script src="../../js/utils/http.utils.js"></script>
	<script src="../../js/mui.min.js"></script>
	<script>
		var $wxfwid = localStorage.getItem("wxfwid");
		var currPage = 0;
		mui.init({
			pullRefresh: {
				container: "#rfc-goodTxtLst",
				up: {
					height: 2,
					auto: true,
					contentrefresh : "加载中...",
					contentnomore:'没有更多数据了',
					callback: fun_loadUpGoodBooksLst
				}
			}
		});
		
		function fun_loadUpGoodBooksLst(){
			fun_loadGoodTxtData(8, currPage);
		}
		
		mui('#rfc-goodTxtLst').on("tap", "a", function(){
			mui.openWindow({
				url : this.href
			});
		});
		
		function fun_goodTxtTem($txt, num) {
			var $goodTxtTem =
				  '<a href="artdetails.html?artid=' + $txt.id + '"><div style="display: flex; margin: 10px 5px 10px 4px;">'
            +   	'<div style="margin: 2px 5px 2px 5px; float: left;">'
            +    		'<img src="' + $txt.thumbnail + '" height="80" width="80" />'
            +    	'</div>'
            +    	'<div style="float: right; margin: 2px 0px 2px 10px; width: 80%;">'
            +    		'<div style="color: #303030; font-size: 16px; width: 100%; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;">' + $txt.title + '</div>'
            +    		'<div style="display: block; margin-top: 30px; color: #303030; font-size: 14px; width: 100%;">'
            +    			'<span style="float: left;"><img src="../../img/jzkt/yanjing_03.png" width="16"/>&nbsp;'+ $txt.readCount +'</span>'
            +   			'<span style="float: right; margin-right: 20px;"><img src="../../img/comm.png" width="16" height="14"/>&nbsp;'+ $txt.commentInfo.commentNum +'</span>'
            +    		'</div>'
            +    	'</div>'
            +    '</div></a><hr style="width: 100%; background-color: #DCDCDC; height: 1px;" />';
			return $goodTxtTem;
		}

		function fun_loadGoodTxtData($psize, $cpage) {
			mui.ajax({
				url: $request_url.getGoodTxtLst,
				type: "get",
				headers: {
					"Authorization": $headers_authorization
				},
				data: {
					orgId: $wxfwid,
					typeCode: "HWSC",
					rows: $psize,
					page: $cpage
				},
				dataType: "json",
				success: function(dat) {
					if(dat.code == 0) {
						var $GoodTxtDoc = document.getElementById("ul-goodTxtLst");
						var $goodTxtLst = dat.result
						if($goodTxtLst != null && $goodTxtLst.length > 0) {
							mui("#rfc-goodTxtLst").pullRefresh().endPullupToRefresh(false); // 加载数据最没有更多内容
							for(var i = 0; i < $goodTxtLst.length; i++) {
								var $gTxtLi = document.createElement('div');
								$gTxtLi.innerHTML = fun_goodTxtTem($goodTxtLst[i], i);
								$GoodTxtDoc.appendChild($gTxtLi);
							}
							currPage ++;
						} else {
							mui("#rfc-goodTxtLst").pullRefresh().endPullupToRefresh(true); // 加载数据最没有更多内容
						}
					} else {
						document.getElementById("ul-goodTxtLst").innerHTML = "<span style='text-align: center;'>暂无好文</span>";
					}
				},
				error: function(err) {

				}
			});
		}
	</script>
</html>
